package com.sc.nft.dto;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.vo.ecology.AdminEcologyCastUserRecordsVO;
import com.sc.nft.entity.vo.ecology.ExpendEcologyCastRecordsVO;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyCastRecords;
import com.sc.nft.mapper.UserEcologyCastRecordsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 生态-铸造-用户记录表(sc_user_ecology_cast_records)数据DAO
 *
 * @author Sun
 * @since 2023-10-13 17:22:12
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyCastRecordsDao extends ServiceImpl<UserEcologyCastRecordsMapper, UserEcologyCastRecords> {

    public Page<ExpendEcologyCastRecordsVO> expendRecords(Long userId, Integer pageNo, Integer pageSize) {
        return baseMapper.expendRecords(new Page<>(pageNo, pageSize), userId);
    }

    public BigDecimal getSumEcologyHatchCastTotalFuelConsumed() {
        return baseMapper.getSumEcologyHatchCastTotalFuelConsumed();
    }

    public BigDecimal getYesterDaySumEcologyPoints() {
        return baseMapper.getYesterDaySumEcologyPoints();
    }

    public BigDecimal getFoundryFuelConsumptionByStartTimeAndEndTime(Date startTime, Date endTime) {
        return baseMapper.getFoundryFuelConsumptionByStartTimeAndEndTime(startTime, endTime);
    }

    public Page<AdminEcologyCastUserRecordsVO> getPageUserRecordsRecords(Long collectionId, Long userId, String startTime, String endTime, Integer pageNo, Integer pageSize) {
        return baseMapper.getPageUserRecordsRecords(new Page<>(pageNo, pageSize), collectionId, userId, startTime, endTime);
    }

    public List<AdminEcologyCastUserRecordsVO> getPageUserRecordsExport(Long collectionId, Long userId, String startTime, String endTime) {
        return baseMapper.getPageUserRecordsExport(collectionId, userId, startTime, endTime);
    }

    public List<ExpendEcologyCastRecordsVO> expendRecordsDetails(Long userId, Long id) {
        return baseMapper.expendRecordsDetails(userId, id);
    }

    public boolean updateWayConfIdByEcologyCastConfId(Long ecologyCastConfId, Long ecologyCastWayConfId) {
        LambdaUpdateWrapper<UserEcologyCastRecords> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(UserEcologyCastRecords::getEcologyCastConfId,ecologyCastConfId);
        lambdaUpdateWrapper.set(UserEcologyCastRecords::getEcologyCastWayConfId,ecologyCastWayConfId);
        return update(lambdaUpdateWrapper);
    }
}